﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace YXShop.TemplateAction
{
    public partial class LabelParse
    {
        public string FreeLabel()
        {
            string mystyle = this.Label_Inserted;
            string showPage = this.GetParamValue("YX:ShowPage");//是否分页
            string showMode = this.GetParamValue("YX:ShowMode"); //布局方式
            string row = this.GetParamValue("YX:ShowRows");  //显示行
            string col = this.GetParamValue("YX:ShowCols");  //显示列
            string lblName = this.GetParamValue("YX:ShowName");  //根据标签名获取SQL
            StringBuilder shtml = new StringBuilder();
            if (string.IsNullOrEmpty(row) && ChangeHope.Common.ValidateHelper.IsNumber(row))
            {
                row = "1";
            }
            if (string.IsNullOrEmpty(col) && ChangeHope.Common.ValidateHelper.IsNumber(col))
            {
                col = "1";
            }
            int count = Convert.ToInt32(row) * Convert.ToInt32(col);
            YXShop.BLL.Templates.FreeLabel freeBll=new YXShop.BLL.Templates.FreeLabel();
            shtml.Append(mystyle);
            YXShop.Model.Templates.FreeLabel freelabel = freeBll.GetListByWhere(" free_name= '" + lblName + "'")[0];      
            if (showPage=="true")
            {
                ChangeHope.DataBase.DataByPage dataPage = freeBll.GetListAll(freelabel.LabelSql, count);
                shtml.Append(dataPage.ReceptionToolBar);
            }
            return shtml.ToString();
        }
    }
}
